function getUser(){
    var name , psd;
    name = getCookie("name");
    psd = getCookie("psd");
    if(name != null){
        document.getElementById('name').value = name;
        document.getElementById('box').checked = true;
    }
    if (psd != null)
        document.getElementById('psd').value = psd;
}



function getCookie(key) {
    var cookies = document.cookie.split(";");
    for(var i=0; i<cookies.length; i++) {
        var t1 = cookies[i]
        var t2 = t1.split(" ");
        var cookie
        if(typeof(t2[1]) != "undefined"){
            cookie = t2[1].split("=");
        }else {
            cookie = t2[0].split("=");
        }
        if (key == cookie[0]) {
            return cookie[1]
        }
    }
}

function getMsg() {
    $.ajax({
        type: "post",
        dataType: "text",
        url: "/jee_war_exploded/ChatRoom",
        data: {"test":"hello"},
        success: function (msg) {
            getChats(msg);
            getCount();
        },
        error : function(errorMsg) {
            document.getElementById("des").innerText = "fail to get data";
        }
    });
}

function getChats(msgs) {
    var div = document.getElementById("show");
    var chats = msgs.split("~")
    for(var i=1; i<chats.length; i++){
        var test = document.createElement("span");
        var space = document.createElement("br");
        test.innerHTML = chats[i];
        div.appendChild(test);
        div.appendChild(space)
    }
}

function getCount() {
    var count = getCookie("count");
    var span = document.getElementById("count");
    span.innerHTML = "当前在线人数： "+count;
}








